package com.showde.shoppingmall.activity;

import com.showde.shoppingmall.R;
import com.showde.shoppingmall.adapter.MoreAdapter;
import com.showde.shoppingmall.utils.ActivityDispatch;

import android.app.ActivityGroup;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

@SuppressWarnings("deprecation")
public class MoreActivity extends BaseActivity {

	ListView moreItemsListView;

	private static final String[] items = new String[] { "账户信息", "客户服务",
			"常见问题", "设置", "留言板", "地址管理", "我的订单", "我的收藏" };

	public static final int ITEM_USERINFO = 0; // 账户信息
	public static final int ITEM_SERVICE = 1; // 客服
	public static final int ITEM_QUESTION = 2; // 常见问题
	public static final int ITEM_SETTINGS = 3; // 设置
	public static final int ITEM_FEEDBACK = 4; // 留言板
	public static final int ITEM_ADDRESS = 5; // 地址管理
	public static final int ITEM_MYBILL = 6; // 我的订单
	public static final int ITEM_MYCOLLECTION = 7; // 我的收藏

	@Override
	public void onClick(View arg0) {

	}

	@Override
	protected void initParam() {
		ActivityGroup activityGroup = ActivityDispatch
				.getActivityGroup(groupTag);
		if (activityGroup == null) {
			groupTag = ActivityDispatch.GROUP_MORE;
		}
	}

	@Override
	protected void initView() {
		setContentView(R.layout.activity_more);
		moreItemsListView = (ListView) findViewById(R.id.lst_more);
		moreItemsListView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1,
					int position, long arg3) {
				onListViewClick(position);
			}
		});
	}

	@Override
	protected void onResume() {
		super.onResume();
		moreItemsListView.setAdapter(new MoreAdapter(this, items));
	}

	private void onListViewClick(int position) {
		Toast.makeText(this, items[position], position).show();
		switch (position) {
		case ITEM_USERINFO:
			// ActivityDispatch.openNewActivity(this, UserInfoActivity.class,
			// MoreGroup.group, "MoreActivity");
			ActivityDispatch.toUserInfo(this);
			break;
		case ITEM_SERVICE:
			ActivityDispatch.toCustomerService(this);
			break;
		case ITEM_QUESTION:
			ActivityDispatch.toNormalQuestion(this);
			break;
		case ITEM_SETTINGS:
			break;
		case ITEM_FEEDBACK:
			ActivityDispatch.toFeedback(this);
			break;
		case ITEM_ADDRESS:
			// ActivityDispatch.toAddressManager(this);
			ActivityDispatch.openNewActivity(MoreActivity.this,
					AddressManagerActivity.class,
					ActivityDispatch.getActivityGroup(groupTag),
					"ProductDetailsActivity", groupTag);
			break;
		case ITEM_MYBILL:
			ActivityDispatch.toBillList(this);
			break;
		case ITEM_MYCOLLECTION:
			ActivityDispatch.toMyCollection(this);
			break;
		}
	}
}
